home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / mflms101.arc / MFLDEFS.H < prev    next >
C/C++ Source or Header  |  1989-11-25  |  4KB  |  122 lines

  1. /************************************************************************/
  2. /*                                                                      */
  3. /*  MFLDEFS Header file                                                 */
  4. /*                                                                      */
  5. /*  Miscellaneous utility definitions for use with the MicroFirm        */
  6. /*  Function Library                                                    */
  7. /*                                                                      */
  8. /*  Copyright 1989 by Robert B. Stout dba MicroFirm                     */
  9. /*  All rights reserved                                                 */
  10. /*                                                                      */
  11. /*  Copyright 1986, 1987 by S.E. Margison                               */
  12. /*                                                                      */
  13. /*  Compiled by QC 2.0 for use with MSC 5.1 or QC 2.0 or later.         */
  14. /*                                                                      */
  15. /************************************************************************/
  16.  
  17. #ifndef MFLDEFS_H
  18. #define MFLDEFS_H
  19.  
  20. /************************************************************************/
  21. /* Miscellaneous #defines                                               */
  22. /************************************************************************/
  23.  
  24. #define Repeat(x) if (x) do
  25. #define Until(x) while(!(x))
  26.  
  27. #ifndef EVER
  28.  #define EVER (;;)    /* e.g. "for EVER {...}"                        */
  29. #endif
  30.  
  31. #define KB_flush() while(kbhit()) getch()
  32. #define Bputc(c) bdos(6,c,0)
  33. #define MAX_FLEN 67
  34.  
  35. /*
  36. **  Use the following for "illegal" casts, e.g. structs or unions to
  37. **  simple data types of the same size, etc.
  38. */
  39.  
  40. #define CAST(new_type,old_object) (*((new_type *)&old_object))
  41.  
  42. #if 0
  43. *************************************************************************
  44. *                                                                       *
  45. *       /* Example of CAST macro at work        */                      *
  46. *                                                                       *
  47. *       union {                                                         *
  48. *               char    ch[4];                                          *
  49. *               int     i[2];                                           *
  50. *       } my_union;                                                     *
  51. *                                                                       *
  52. *       long    longvar;                                                *
  53. *                                                                       *
  54. *               longvar = (long)my_union;       /* Illegal cast */      *
  55. *               longvar = CAST(long, my_union); /* Legal cast   */      *
  56. *                                                                       *
  57. *************************************************************************
  58. #endif  /* 0 */
  59.  
  60. #ifndef MK_FP
  61.  #define MK_FP(seg,offset) \
  62.     ((void far *)(((unsigned long)(seg)<<16) | (unsigned)(offset)))
  63. #endif
  64.  
  65. #ifndef offsetof
  66.  #define offsetof(st,el) (size_t)&(((st *)0)->el)
  67. #endif
  68.  
  69. #ifndef NUL
  70.  #define NUL '\000'
  71. #endif
  72.  
  73. #ifndef BEL
  74.  #define BEL '\007'
  75. #endif
  76.  
  77. #ifndef EINVFNC
  78.  #define EINVFNC 1
  79. #endif
  80.  
  81. #define __PAGE(title)
  82.  
  83. #ifdef TRUE
  84.  #undef TRUE
  85. #endif
  86.  
  87. #ifdef FALSE
  88.  #undef FALSE
  89. #endif
  90.  
  91. typedef enum {ERROR = -1, FALSE, TRUE} LOGICAL;
  92.  
  93. #ifndef BOOL
  94.  #define BOOL(x) (!(!(x)))
  95. #endif
  96.  
  97. #ifndef SUCCESS
  98.  #define SUCCESS 0    /* e.g. if (SUCCESS == fclose(...))     */
  99. #endif
  100.  
  101. #define BitSet(arg,posn) (arg | (1L << posn))
  102. #define BitClr(arg,posn) (arg & ~(1L << posn))
  103. #define BitTst(arg,posn) ((arg & (1L << posn)) ? TRUE : FALSE)
  104.  
  105. #define LP1 0    /* printer numbers */
  106. #define LP2 1
  107. #define LP3 2
  108. #define SER1 0    /* COM1 port */
  109. #define SER2 1    /* COM2 port */
  110. #define SER3 2    /* COM3 port */
  111. #define SER4 3    /* COM4 port */
  112. #define NONE 0    /* no parity */
  113. #define ODD 1     /* odd parity */
  114. #define EVEN 2    /* even parity */
  115.  
  116. #define GAMEPORT 0x201        /* gameport address */
  117. #define IDLE 0                /* state definitions for debouncer */
  118. #define INPROG 1
  119. #define WAITOPEN 2
  120.  
  121. #endif /* MFLDEFS_H */
  122.